﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PokerStatisticsCalculator
{
    internal class ArrayEqualityComparer : EqualityComparer<Array>
    {
        private static ArrayEqualityComparer instance = new ArrayEqualityComparer();
        public static ArrayEqualityComparer Instance { get { return instance; } }

        private ArrayEqualityComparer ()
        {
        }

        public override bool Equals(Array x, Array y)
        {
            return x.OfType<object>().SequenceEqual(y.OfType<object>());
        }

        public override int GetHashCode(Array array)
        {
            return array.OfType<object>().Aggregate<object, int>(0, (agg, value) => agg ^ value.GetHashCode());
        }
    }
}